package com.example.cinema.mapper;

import com.example.cinema.entity.Studios;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yc138
 * @since 2024-08-26
 */
@Repository
public interface StudiosMapper extends BaseMapper<Studios> {
    @Select("select * from studios")
    @Results(id="rm1",
    value = {
            @Result(column = "id",property = "id",id = true),
            @Result(column = "id",property = "halls",many = @Many(
                    select="com.example.cinema.mapper.HallMapper.selectByStuId"
            ))
    })
    List<Studios> selectAll();

    @Select("select * from studios where id=#{id}")
    Studios selectById(int id);

//////
    @Select("select * from studios limit #{current},#{size}")
    @Results(id="queryStudios",
            value = {
                    @Result(column = "id",property = "id",id = true),
                    @Result(column = "id",property = "halls",many = @Many(
                            select="com.example.cinema.mapper.HallMapper.selectByStuId"
                    ))
            })
    List<Studios> queryStudios(@Param("current") int current, @Param("size") int size);
}
